package com.example.appcomedores;

import java.util.ArrayList;

import com.example.appcomedoresproject.R;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemLongClickListener;

/**
 * Created by Administrador on 28/08/13.
 */
public class Comentarios extends Activity implements OnClickListener{

    // Array of options --> ArrayAdapter --> ListView

    //List view: {views: da_items.xml}
	ArrayList<String> listcoment = new ArrayList<String>();
	ArrayAdapter<String> adapter;
	TextView tvTit;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.actividad_comentario);
        
        tvTit=(TextView)findViewById(R.id.tvTitle);
        
        
        
    
    
        //Create list of items
        listcoment.add("Comida mala");
        listcoment.add("Comida buena");
        listcoment.add("Comida mas o menos");
        listcoment.add("Comida sabrosa");
        //Build Adapter
        adapter = new ArrayAdapter<String>(
                this,               //Context for the activity.
                R.layout.da_item,   //Layout to use (create)
                listcoment);           //Items to be displayed

        //Configure the list view.
        ListView list =(ListView)findViewById(R.id.listViewMain);
        list.setAdapter(adapter);
        list.setOnItemLongClickListener(new OnItemLongClickListener() {
            // setting onItemLongClickListener and passing the position to the function
                      @Override
            public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                    int position, long arg3) {
                    	  listcoment.remove(position);
                          adapter.notifyDataSetChanged(); 
                          String message ="El Comentario fue eliminado";
                          //Presenta el comentario
                          Toast.makeText(Comentarios.this, message, Toast.LENGTH_LONG).show();
                
                return true;
            }
        });
    
        
       /* list.setOnItemClickListener(new AdapterView.OnItemClickListener(){
            @Override
            public void onItemClick(AdapterView<?> paret, View viewClicked, int position, long id) {
                //TextView textView = (TextView)viewClicked;
                String message ="Su Comentario fue eliminado";
                //Presenta el comentario
                Toast.makeText(Comentarios.this, message, Toast.LENGTH_LONG).show();
            }
        });*/


        
}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		
	}
}
